const mongoose = require('./db')

const userSchema = new mongoose.Schema({
    username: String,//电话或者邮箱
    password: String,     //密码--加密
    name: String,       //姓名--需要验证
    code: String,      //身份证-需要验证
    port: String,     //头像
    tel: String,     //电话
    city: String,         //所在地
    age: Number,                //年龄
    sex:String,               //性别
    introduce: String//个人介绍
})

const userModel = mongoose.model('userlist', userSchema, 'userlist')



const patientSchema = new mongoose.Schema({
    name: String,
    picture:  String,//照片路径
    sex:  String,
    age:  Number,
    weight: Number,
    race: String,
    job: String,
    education:  String,
    marital: Boolean,
    address:  String,
    tel:  String,
    religious:  String,
    medicalRecord: Array//病历
    // [
    //     {
    //         startTime: String,
    //         endTime: String,
    //         address: String,
    //         reason: String,
    //         hospital: String,
    //         plan: String,
    //     }
    // ],
})

const patientModel = mongoose.model('patientlist', patientSchema, 'patientlist')

const addressSchema = new mongoose.Schema({
    title: String,
    person: String,
    tel: String,
    province: String,
    city:String,
    address: String,
})

const addressModel = mongoose.model('addresslist', addressSchema, 'addresslist')


const shopSchema = new mongoose.Schema({
    cate: String,//问诊 | 服药
    status: String,
    doctor: String,
    tel: String,
    time: String,
    part: String,
    hospital:String,
    money: String,
    pid:{
        type:[mongoose.Types.ObjectId],
        ref:"patientlist"
    },
    uid:{
        type:[mongoose.Types.ObjectId],
        ref:"userlist"
    },
})

const shopModel = mongoose.model('shoplist', shopSchema, 'shoplist')

const medinceSchema = new mongoose.Schema({
    cate: String,//问诊 | 服药
    name: String,
    num: Number,
    cate: String,
    time: String,
    cid:{
        type:[mongoose.Types.ObjectId],
        ref:"comment1list"
    },
    uid:{
        type:[mongoose.Types.ObjectId],
        ref:"userlist"
    },
})

const medinceModel = mongoose.model('medincelist', medinceSchema, 'medincelist')

const comment1Schema = new mongoose.Schema({
    time: String,
    content: String,
    uid:{//用来查看评论人和头像
        type:[mongoose.Types.ObjectId],
        ref:"userlist"
    },
})

const comment1Model = mongoose.model('comment1list', comment1Schema, 'comment1list')

const doctorSchema = new mongoose.Schema({
    name: String,
    title: String,
    part: String,
    hostipal:String,
    content: String,
    money: String,
    cid:{
        type:[mongoose.Types.ObjectId],
        ref:"comment2list"
    },
})

const doctorModel = mongoose.model('doctorlist', doctorSchema, 'doctorlist')





const comment2Schema = new mongoose.Schema({//医生评论
    time: String,
    content: String,
    uid:{//用来查看评论人和头像
        type:[mongoose.Types.ObjectId],
        ref:"userlist"
    },
})

const comment2Model = mongoose.model('comment2list', comment2Schema, 'comment2list')


module.exports = {
    userModel,
}